"use strict";
cc._RF.push(module, '64c395gvrpAUqMXbmjdx0u6', 'Smoother');
// cases/Smoother.ts

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Smoother = void 0;
var tmpv2 = cc.v2();
var Smoother = /** @class */ (function () {
    function Smoother(sampleSize) {
        this._list = [];
        this._nextUpdateSlot = 0;
        this._maxSampleSize = 0;
        this._nextUpdateSlot = 0;
        this._maxSampleSize = sampleSize;
    }
    Smoother.prototype.onUpdate = function (recentValue) {
        var v = this._list[this._nextUpdateSlot];
        if (!v) {
            v = cc.v2(recentValue);
            this._list[this._nextUpdateSlot] = v;
        }
        else {
            v.set(recentValue);
        }
        this._nextUpdateSlot++;
        if (this._nextUpdateSlot >= this._maxSampleSize)
            this._nextUpdateSlot = 0;
        tmpv2.set(cc.Vec2.ZERO);
        for (var i = 0, len = this._list.length; i < len; i++) {
            cc.Vec2.add(tmpv2, this._list[i], tmpv2);
        }
        tmpv2.divSelf(this._list.length);
        return tmpv2;
    };
    return Smoother;
}());
exports.Smoother = Smoother;

cc._RF.pop();